/*
 * @Author: c
 * @Date: 2024-01-24 13:33:55
 * @LastEditTime: 2024-01-30 03:46:57
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\core\music\rate_file_info\dto\index.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// Copyright 2024 Administrator
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { IsBoolean, IsEnum, IsNumber, IsOptional, IsString } from "class-validator";
import { AudioRateEnum } from "src/common/enums/audio.enum";
import { FileFormatEnum, MimeEnum, StatusTypeEnum } from "src/core/system/minio/enum";
import { UploadFile } from "../../song/dto/create-song.dto";
import { Transform } from "class-transformer";

export class RateFileInfoDto {
    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "音质id格式不正确" })
    id?: number;

    //音频质量
    @IsEnum(AudioRateEnum, { message: "音频质量格式不正确" })
    @IsString()
    rate: AudioRateEnum;

    //资源的size大小
    @IsOptional()
    @Transform(v => +v)
    @IsNumber({ allowNaN: false }, { message: "音质size格式不正确" })
    size: number;

    //资源的格式
    @IsEnum(FileFormatEnum, { message: "音频格式不正确" })
    format: FileFormatEnum;

    //歌曲时长
    @Transform(v => +v)
    @IsNumber({ allowNaN: false }, { message: "音频时长不正确" })
    duration: number;

    //是否是完整的
    @IsBoolean({ message: "是否是试听必传" })
    isFull: boolean;

    @IsOptional()
    @IsNumber({ allowNaN: false }, { message: "音频时长不正确" })
    percentage?: number;



    @IsNumber({ allowNaN: false }, { message: "音频上传进度不正确" })
    transformProgress: number;

    //文件
    @IsOptional()
    file?: UploadFile;



    // // @IsOptional()
    // blob?: Blob;

    @IsOptional()
    @IsEnum(MimeEnum, { message: "音频mimetye不正确" })
    mimeType?: MimeEnum;

    //操作状态
    @IsOptional()
    @IsEnum(StatusTypeEnum, { message: "操作状态类型不正确" })
    status?: StatusTypeEnum;

    //资源名称
    @IsOptional()
    @IsString({ message: "音频文件名称不正确" })
    name?: string;

    //上传完成返回的文件id
    @IsString({ message: "上传完成返回的文件id格式不正确" })
    fileId: string;
}